﻿program Game;

//{$APPTYPE CONSOLE}
{$ifdef fpc} {$mode delphi} {$endif}

uses
  SysUtils,
  Classes,

  zglHeader,
  zglChipmunk,

  GameAbstract,

  GameAbstract_Types,
  GameAbstract_Utils,
  GameAbstract_Format,
  GameAbstract_Events,
  GameAbstract_Room,
  GameAbstract_Sprite,
  GameAbstract_Blend;


  var
   Tex1, Tex2, Mask: TGameTexture;
   Blend: TGameBlendTexture;
   Sp1, Sp2, SpM, SpB: TGameSprite;
   Room: TGameRoom;


procedure LoadData;
begin
   Tex1  := TGameTexture.Create;
   Tex1.LoadFromFile('../blending/tile1.png');

   Tex2  := TGameTexture.Create;
   Tex2.LoadFromFile('../blending/tile2.png');

   Mask  := TGameTexture.Create;
   Mask.LoadFromFile('../blending/mask.png');

   Blend := TGameBlendTexture.Create( Mask.FrameWidth, Mask.FrameHeight );
   Blend.SetTextures(Tex1, Tex2, Mask);


   SpB := TGameSprite.Create(326, 200, Tex1.FrameWidth, Tex1.FrameHeight);
   SpB.Texture := Blend;
end;

procedure MyInit( Event: TGameEvent; Param: Integer; dt: Double );
begin
  LoadData;
  Room := TGameRoom.Create;
  Room.Add(SpB);
end;


begin
  GameEngine := TGameEngine.Create('../../game/ZenGl.dll');
  GameEngine.OnInit.Add(MyInit);

  if GameEngine.IsReady then
  begin
     GameEngine.LoadPhysics('../../game/chipmunk.dll');
     GameEngine.Caption      := 'Filter';
     GameEngine.ScreenWidth  := 800;
     GameEngine.ScreenHeight := 600;

     wnd_ShowCursor(TRUE);

     GameEngine.Init;
  end;
end.
